package com.sendpo.zjx.sendpo.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sendpo.zjx.sendpo.R;
import com.sendpo.zjx.sendpo.domain.JobDomain;
import com.sendpo.zjx.sendpo.utils.Tools;
import com.sendpo.zjx.sendpo.views.MainScrollview;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/8/14.
 */

public class ZhaoPinInfoActivity extends AppCompatActivity {
    public JobDomain.DataBean dataBean;
    public int type = 0;
    @BindView(R.id.backbt)
    RelativeLayout backbt;
    @BindView(R.id.head)
    RelativeLayout head;
    @BindView(R.id.yinpin_bt)
    Button yinpinBt;
    @BindView(R.id.bottom)
    RelativeLayout bottom;
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.datetime)
    TextView datetime;
    @BindView(R.id.money)
    TextView money;
    @BindView(R.id.location)
    TextView location;
    @BindView(R.id.person_iv)
    ImageView personIv;
    @BindView(R.id.person_rl)
    RelativeLayout personRl;
    @BindView(R.id.jingyan_iv)
    ImageView jingyanIv;
    @BindView(R.id.jingyan_rl)
    RelativeLayout jingyanRl;
    @BindView(R.id.xueli_iv)
    ImageView xueliIv;
    @BindView(R.id.xueli_rl)
    RelativeLayout xueliRl;
    @BindView(R.id.location_left)
    RelativeLayout locationLeft;
    @BindView(R.id.location_right)
    RelativeLayout locationRight;
    @BindView(R.id.company_left)
    RelativeLayout companyLeft;
    @BindView(R.id.company_right)
    RelativeLayout companyRight;
    @BindView(R.id.zhiye_left)
    RelativeLayout zhiyeLeft;
    @BindView(R.id.zhiye_right)
    RelativeLayout zhiyeRight;
    @BindView(R.id.maincrollview)
    MainScrollview maincrollview;
    @BindView(R.id.person_tv)
    TextView personTv;
    @BindView(R.id.experience_tv)
    TextView experienceTv;
    @BindView(R.id.work_tv)
    TextView workTv;
    @BindView(R.id.companyname_tv)
    TextView companynameTv;
    @BindView(R.id.description)
    TextView description;
    @BindView(R.id.education_tv)
    TextView educationTv;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_zhaopininfo);
        ButterKnife.bind(this);
        Tools.initStatus(this, R.color.black);
        initComponent();
    }

    private void initComponent() {
        dataBean = (JobDomain.DataBean) getIntent().getSerializableExtra("data");
        type = getIntent().getIntExtra("type", 0);
        switch (type) {
            case 0:
                yinpinBt.setVisibility(View.VISIBLE);
                break;
            case 1:
                yinpinBt.setVisibility(View.GONE);
                break;
        }
        if (dataBean != null) {
            title.setText("" + dataBean.getJobName());
            datetime.setText("" + dataBean.getJobCreatetime());
            money.setText("" + dataBean.getJobSalary() + "/月");
            location.setText("" + dataBean.getCompanyCity() + "-" + dataBean.getCompanyArea());
            personTv.setText("招" + dataBean.getJobPeoplenum() + "人");
            experienceTv.setText("" + dataBean.getJobExperience() + "以上经验");
            workTv.setText("上班地点：" + dataBean.getCompanyCity() + dataBean.getCompanyArea() + dataBean.getCompanyAddress());
            educationTv.setText(""+dataBean.getJobEducation());
            companynameTv.setText(""+dataBean.getCompanyName());
            description.setText(""+dataBean.getJobDescription());
        }
    }

    @OnClick(value = {R.id.backbt, R.id.yinpin_bt})
    public void onMyClick(View view) {
        switch (view.getId()) {
            case R.id.backbt:
                finish();
                break;
            case R.id.yinpin_bt:
                if(dataBean==null){
                    return;
                }
                Map<String,Object> map=new HashMap<>();
                map.put("jobId",dataBean.getJobId());
                Tools.redirectActivity(this, YinPinzheUserActivity.class,map);
                break;

        }
    }
}
